package com.heima.behavior.controller.v1;

import com.heima.behavior.service.BehaviorService;
import com.heima.model.behavior.dtos.LikesBehaviorDto;
import com.heima.model.behavior.dtos.ReadBehaviorDto;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 熏橙橙
 * @version 1.0
 * @date 2023-08-02 11:35
 */
@RestController
@RequestMapping("/api/v1")
@Slf4j
public class BehaviorController {

    @Autowired
    private BehaviorService behaviorService;

    /**
     * redis存储点赞
     * 或者取消点赞
     * @param dto
     * @return
     */
    @PostMapping("/likes_behavior")
    public ResponseResult likes_behavior(@RequestBody LikesBehaviorDto dto){
        return behaviorService.likes(dto);
    }

    /**
     * redis存储阅读习惯
     * @param dto
     * @return
     */
    @PostMapping("/read_behavior")
    public ResponseResult read_behavior(@RequestBody ReadBehaviorDto dto) {
        return behaviorService.read(dto);
    }

    /**
     * redis存储不喜欢文章
     * @param dto
     * @return
     */
    @PostMapping("/un_likes_behavior")
    public ResponseResult un_likes_behavior(@RequestBody UnLikesBehaviorDto dto){
        return behaviorService.un_likes(dto);
    }
}
